<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateSearchLog extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysqlDataStatistics')
              ->create('search_log', function (Blueprint $table) {
                  $table->id();
                  $table->unsignedInteger('customerId')->default(0)->comment('用户Id');
                  $table->unsignedInteger('shopId')->default(0)->comment('门店Id');
                  $table->tinyInteger('source')->default(0)->comment('来源 1-微信点餐小程序搜索');
                  $table->string('content', 255)->default('')->comment('搜索内容');

                  $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
                  $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
                  $table->unsignedInteger('isDeleted')->default(0);
                  $table->collation = 'utf8mb4_general_ci';
                  $table->comment   = '通用搜索日志';

                  $table->index('customerId', 'idx_customerId');
                  $table->index('shopId', 'idx_shopId');
              });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('search_log');
    }
}
